package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.AddNursingPlanDto;
import com.zzyl.dto.NursingPlanSearchDTO;
import com.zzyl.dto.UpdateNursingPlanDto;
import com.zzyl.entity.NursingPlan;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanDetailVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "护理计划")
@RequestMapping("/nursing/plan")
@RestController
public class NursingPlanController {

    @Autowired
    private NursingPlanService nursingPlanService;

    @ApiOperation("护理计划分页查询")
    @GetMapping("/search")
    public ResponseResult<PageResponse<NursingPlan>> search(NursingPlanSearchDTO dto){
        PageResponse<NursingPlan> page = nursingPlanService.search(dto);
        return ResponseResult.success(page);
    }


    @ApiOperation("新增护理计划")
    @PostMapping
    public ResponseResult add(AddNursingPlanDto dto){
        nursingPlanService.add(dto);
        return ResponseResult.success();
    }

    @ApiOperation("修改护理计划")
    @PutMapping
    public ResponseResult update(UpdateNursingPlanDto dto){
        nursingPlanService.update(dto);
        return ResponseResult.success();
    }

    @ApiOperation("根据id获取护理计划详情")
    @GetMapping("{id}")
    public ResponseResult<NursingPlanDetailVo> getDetails(@PathVariable("id")Long id){
        NursingPlanDetailVo vo = nursingPlanService.getDetails(id);
        return ResponseResult.success(vo);
    }

    @ApiOperation("根据id删除护理计划")
    @DeleteMapping("{id}")
    public ResponseResult delete(@PathVariable("id")Long id){
        nursingPlanService.delete(id);
        return ResponseResult.success();
    }



}